package javabasic.threads;

public class DiffNotifyYield2 {
    public static void main(String[] args) {
        //调用Thread.yield()方法时，会给线程调度器一个当前线程愿意CPU执行时间片的提示，但是线程调度器也可能忽略这个提示
        RunnabeTest runnabeTest = new RunnabeTest() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println(Thread.currentThread().getName() + "---" + i);
                    if (i == 5) {
                        Thread.yield();
                    }
                }
            }
        };
        Thread ta = new Thread(runnabeTest);
        Thread tb = new Thread(runnabeTest);
        ta.start();
        tb.start();
    }
}
